From 12693c6fe31692d42552793a227d280917d35d6e Mon Sep 17 00:00:00 2001 From: Daniel Boles Date: Wed, 23 Aug 2017 21:44:10 +0100 Subject: [PATCH] Popover: Include window shadows in overshoot calcs .update_position() enforces that non-Wayland platforms must position a Popover within its parent Window. We use the allocation of the Window to translate the position and check for overshoot on each of its sides. Calling Widget.get_allocation() of a CSD Window includes its shadows. But shadows were not excluded from the area in which we can position. Thus, Popovers could get positioned in the shadow of CSD windows, where, at least on X11, no input is received. Therefore, positioning a Popover over a shadow meant its child widgets within that area became unusable. Fix by calling Window.get_shadow() and including it in the overshoot on each side. This adjusts for how the allocation includes shadows, making overshoots with and without shadows the same. Thus, we avoid considering shadows as viable for positioning, favouring a side where input works. https://bugzilla.gnome.org/show_bug.cgi?id=786209 --- gtk/gtkpopover.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index f52d7b54ad..3f787fd9a1 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -1099,6 +1099,7 @@ gtk_popover_update_position (GtkPopover *popover) GtkPopoverPrivate *priv = popover->priv; GtkWidget *widget = GTK_WIDGET (popover); GtkAllocation window_alloc; + GtkBorder window_shadow; GdkRectangle rect; GtkRequisition req; GtkPositionType pos; @@ -1111,6 +1112,7 @@ gtk_popover_update_position (GtkPopover *popover) gtk_widget_get_preferred_size (widget, NULL, &req); gtk_widget_get_allocation (GTK_WIDGET (priv->window), &window_alloc); + _gtk_window_get_shadow_width (priv->window, &window_shadow); priv->final_position = priv->preferred_position; gtk_popover_get_pointing_to (popover, &rect); @@ -1119,10 +1121,12 @@ gtk_popover_update_position (GtkPopover *popover) pos = get_effective_position (popover, priv->preferred_position); - overshoot[GTK_POS_TOP] = req.height - rect.y; - overshoot[GTK_POS_BOTTOM] = rect.y + rect.height + req.height - window_alloc.height; - overshoot[GTK_POS_LEFT] = req.width - rect.x; - overshoot[GTK_POS_RIGHT] = rect.x + rect.width + req.width - window_alloc.width; + overshoot[GTK_POS_TOP] = req.height - rect.y + window_shadow.top; + overshoot[GTK_POS_BOTTOM] = rect.y + rect.height + req.height - window_alloc.height + + window_shadow.bottom; + overshoot[GTK_POS_LEFT] = req.width - rect.x + window_shadow.left; + overshoot[GTK_POS_RIGHT] = rect.x + rect.width + req.width - window_alloc.width + + window_shadow.right; #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)) && -- 2.30.2